<template>
  <a-card :bordered="false">
      <!-- 查询区域 -->
    <div class="table-page-search-wrappe">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="团队名称">
              <select-team-input
                :multi="true"
                placeholder="请选择团队"
                v-model="queryParam.teamIdList"
                :teamType="0"
                :tdlx="3"/>
            </a-form-item>
          </a-col>
          <!--2022年11月23日20:34:52 找产品问的-->
<!--          <a-col :xl="6" :lg="7" :md="8" :sm="24">-->
<!--            <a-form-item label="参保单位">-->
<!--              <select-company-input placeholder="请选择参保单位" :multi="true" v-model="queryParam.companyIdList"/>-->
<!--            </a-form-item>-->
<!--          </a-col>-->
          <a-col :xl="10" :lg="11" :md="12" :sm="24">
              <a-form-item label="面试时间">
                <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="queryParam.queryJoinDateStart"></j-date>
                <span class="query-group-split-cust"></span>
                <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="queryParam.queryJoinDateEnd"></j-date>
              </a-form-item>
            </a-col>
          <template v-if="toggleSearchStatus">
            
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <!-- <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a> -->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button type="primary" icon="download" @click="handleExportXls('招聘分析')" :disabled="isDisabledAuth('erpHrReportRecruit:export')">导出</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:'100%'}"
        :components="draggableComponent"
        bordered
        rowKey="teamId"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        :customRow="customRow"
        @change="handleTableChange">
        <template slot="status" slot-scope="status">
           <a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
            <a-button
                class="ruleButton"
                :ghost="true"
                type="primary"
                icon="edit"
                @click="handleEdit(record)"
                :disabled="isDisabledAuth('erpHrReportRecruit:edit')"
        />
        <a-divider type="vertical"/>
        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a-button
                    class="ruleButton"
                    :ghost="true"
                    type="primary"
                    icon="delete"
                    :disabled="isDisabledAuth('erpHrReportRecruit:delete')"/>
        </a-popconfirm>
        </span>

      </a-table>
    </div>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {DisabledAuthFilterMixin} from '@/mixins/DisabledAuthFilterMixin'
  import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
  import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
  import moment from 'moment';
  export default {
    name: 'ErpHrReportRecruitList',
    mixins:[JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
    components: {
      SelectCompanyInput,
      SelectTeamInput,
    },
    data () {
      return {
        description: 'erp_hr_report_recruit管理页面',
        //表头
        columns:[],
        //列设置
        settingColumns:[],
        // 列定义
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'团队',
            align:"center",
            width:200,
            dataIndex: 'teamName',
            ellipsis: true
          },
          {
            title:'面试数量',
            align:"center",
            width:200,
            dataIndex: 'interviewCount',
            ellipsis: true
          },
          {
            title:'通过数量',
            align:"center",
            width:200,
            dataIndex: 'accessCount',
            ellipsis: true
          },
          {
            title:'录用数量',
            align:"center",
            width:200,
            dataIndex: 'checkInCount',
            ellipsis: true
          },
          {
            title:'入职数量',
            align:"center",
            width:200,
            dataIndex: 'docCount',
            ellipsis: true
          },
          {
            title:'录用率(%)',
            align:"center",
            width:200,
            dataIndex: 'checkInPercent',
            ellipsis: true
          },
          {
            title:'入职率(%)',
            align:"center",
            width:200,
            dataIndex: 'docPercent',
            ellipsis: true
          }
        ],
        url: {
          list: "/api/erp/hr/report/recruitanalysis/erpHrReportRecruit/list",
          exportXlsUrl: "/api/erp/hr/report/recruitanalysis/erpHrReportRecruit/exportXls",
        },
        dictOptions:{},
        queryParam:{
          queryJoinDateStart: moment(moment().year(moment().year()).startOf('year').valueOf()).format('YYYY-MM-DD'),
          queryJoinDateEnd: moment().endOf('day').format('YYYY-MM-DD')
        }
      }
    },
    created() {
      // this.initQueryParam()
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      initQueryParam(){
        // 获取当前年的第一天
        let newDayOne = new Date().getFullYear() + '-01-01'
        this.$set(this.queryParam, 'queryJoinDateStart',newDayOne)
      },
      searchReset(){
        this.queryParam = {
          queryJoinDateStart: moment(moment().year(moment().year()).startOf('year').valueOf()).format('YYYY-MM-DD'),
            queryJoinDateEnd: moment().endOf('day').format('YYYY-MM-DD')
        }
        this.searchQuery()
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
